import request from '@/config/axios'

// 协议库 VO
export interface StandardsVO {
  id: number // 主键
  serialNumber: string // 序号/索引
  fieldName: string //  字段
  unit: string // 单位
  coefficientK: string // 系数k
  coefficientB: string // 系数b
  dataType: string // 数据类型
  chMean: string // 中文含义
  calculMethod: string // 计算方法
  witsCode: string // WITS码
  deviceType: string // 仪器类型
  deviceMode: string // 仪器型号
  length: number // 长度
  state: boolean // 状态
  remark: string // 备注
  label: undefined,
  value : undefined,
}

// 协议库 API
export const StandardsApi = {
  // 查询协议库分页
  getStandardsPage: async (params: any) => {
    return await request.get({ url: `/base/standards/page`, params })
  },

  // 查询协议库详情
  getStandards: async (id: number) => {
    return await request.get({ url: `/base/standards/get?id=` + id })
  },

  // 新增协议库
  createStandards: async (data: StandardsVO) => {
    return await request.post({ url: `/base/standards/create`, data })
  },

  // 修改协议库
  updateStandards: async (data: StandardsVO) => {
    return await request.put({ url: `/base/standards/update`, data })
  },

  // 删除协议库
  deleteStandards: async (id: number) => {
    return await request.delete({ url: `/base/standards/delete?id=` + id })
  },

  // 导出协议库 Excel
  exportStandards: async (params) => {
    return await request.download({ url: `/base/standards/export-excel`, params })
  },


  //获取父级字典数据列表
  getDeviceType: async (type: any) => {
    return await request.get({ url: `/system/dict-data/getdicttype?params=` + type })
  },
  //获取父级字典下对应仪器类型数据列表
  getDeviceList: async (params: any) => {
    return await request.get({ url: `/base/device-base/getlist` , params })
  },

  // //获取仪器型号信息列表
  // getModeList: async (query: any) => {
  //   return await request.get({ url: `/system/dict-data/getdevicemode?mode=` + query })
  // },

  // 下载用户导入模板
  importTemplate: async () => {
    return await request.download({ url: '/base/standards/downTemplate' })
  },
  //导入excel数据
  reportDepartment: async (data) => {
    return await request.post({ url: '/base/standards/reportDepartment', data })
  },
  //下载错误报告
  downloadWrongReport: async (data) => {
    return await request.download1({ url: '/base/standards/downloadWrongReport', data })
  },



}
